﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace SharpDiary.Core.Controls
{
    public class PanelEx : Panel
    {
        private Color _borderColor = Color.WhiteSmoke;
        private Pen _borderPen = new Pen(Brushes.WhiteSmoke, 1);

        /// <summary>
        /// 获取或设置边框颜色。
        /// </summary>
        public Color BorderColor
        {
            get { return _borderColor; }
            set
            {
                _borderColor = value;
                _borderPen = new Pen(_borderColor, 1);

                Invalidate();
            }
        }

        public PanelEx() { DoubleBuffered = true; ResizeRedraw = true; }

        protected override void OnPaintBackground(PaintEventArgs e)
        {
            base.OnPaintBackground(e);

            switch (BorderStyle)
            {
                case BorderStyle.FixedSingle:
                    {
                        Rectangle rect = ClientRectangle;
                        rect.Width -= 1;
                        rect.Height -= 1;

                        e.Graphics.DrawRectangle(_borderPen, rect);

                        break;
                    }
            }
        }

       
    }
}
